﻿using com.iot.core.annotation;
using com.iot.core.boot;
using com.iot.core.data;
using com.iot.core.data.entity;
using com.iot.core.infrastructure;
using com.iot.core.manager.htcls;
using com.iot.ht.Controllers.htuser.data;
using com.iot.ht.Controllers.htuser.service;
using Microsoft.AspNetCore.Mvc; 

namespace com.iot.ht.Controllers.htuser
{
    [ApiController]
    [Route("[controller]/[action]")]
    [Tag(Name = "用户管理", Description = "")]
    public class HtUserController : ControllerBase
    {
        private readonly IHtUserService baseService;
        
        public HtUserController(IHtUserService p1)
        {
            baseService = p1;
        }


        [HttpPost]
        [Operation(Summary = "用户分页", Description = "")]
        [Auth(AuthType.Login)]
        [Log(LogNeed = false, LogPin = false, LogPout = false, LogTemplete = "")]
        public async Task<Page<HtUserDto>> PageAsync([FromBody] HtUserQto mm)
        { 
            var r =await baseService.PageAsync(mm);
            return r;
        }


        [HttpPost]
        [Operation(Summary = "用户详情", Description = "")]         
        [Auth(AuthType.Login)]
        [Log(LogNeed = false, LogPin = false, LogPout = false, LogTemplete = "")]
        public async Task<HtUserDto> DetailAsync(HtUserDetailQto qm)
        {
            return await baseService.DetailAsync(qm);
        }

        [HttpPost]
        [Operation(Summary = "插入初始化", Description = "")]
        [Auth(AuthType.Login)]
        [Log(LogNeed = false, LogPin = false, LogPout = false, LogTemplete = "")]
        public    HtUserDto InsertInit(BaseQto qm)
        {
            return   baseService.InsertInit(qm);
        }

        [HttpPost]
        [Operation(Summary = "添加用户", Description = "")]
        [Auth(AuthType.Auth)]
        [Log(LogNeed = true, LogPin = true, LogPout = true, LogTemplete = "")]
        public int Insert(HtUserDto qm)
        {
            return baseService.Insert(qm);
        }

        [HttpPost]
        [Operation(Summary = "修改用户", Description = "")]
        [Auth(AuthType.Auth)]
        [Log(LogNeed = true, LogPin = true, LogPout = true, LogTemplete = "")]
        public int Update(HtUserDto qm)
        {
            return baseService.Update(qm);
        }

        [HttpPost]
        [Operation(Summary = "删除用户", Description = "")]
        [Auth(AuthType.Auth)]
        [Log(LogNeed = true, LogPin = true, LogPout = true, LogTemplete = "")]
        public int Delete(BaseQto qm)
        {
            return baseService.Delete(qm);
        }


        [HttpPost]
        [Operation(Summary = "启用用户", Description = "")]
        [Auth(AuthType.Auth)]
        [Log(LogNeed = true, LogPin = true, LogPout = true, LogTemplete = "")]
        public int Qy(BaseQto qm)
        {
            return baseService.Qy(qm);
        }

        [HttpPost]
        [Operation(Summary = "停用用户", Description = "")]
        [Auth(AuthType.Auth)]
        [Log(LogNeed = true, LogPin = true, LogPout = true, LogTemplete = "")]
        public int Ty(BaseQto qm)
        {
            return baseService.Ty(qm);
        }

    }
}
